package bean;

public class Intersection {
	private int id;
	private Point n1, n2, e1, e2, s1, s2, w1, w2;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Point getN1() {
		return n1;
	}

	public void setN1(Point n1) {
		this.n1 = n1;
	}

	public Point getN2() {
		return n2;
	}

	public void setN2(Point n2) {
		this.n2 = n2;
	}

	public Point getE1() {
		return e1;
	}

	public void setE1(Point e1) {
		this.e1 = e1;
	}

	public Point getE2() {
		return e2;
	}

	public void setE2(Point e2) {
		this.e2 = e2;
	}

	public Point getS1() {
		return s1;
	}

	public void setS1(Point s1) {
		this.s1 = s1;
	}

	public Point getS2() {
		return s2;
	}

	public void setS2(Point s2) {
		this.s2 = s2;
	}

	public Point getW1() {
		return w1;
	}

	public void setW1(Point w1) {
		this.w1 = w1;
	}

	public Point getW2() {
		return w2;
	}

	public void setW2(Point w2) {
		this.w2 = w2;
	}

	public Point get(int index) {
		switch (index) {
		case 0:
			return n1;
		case 1:
			return n2;
		case 2:
			return e1;
		case 3:
			return e2;
		case 4:
			return s1;
		case 5:
			return s2;
		case 6:
			return w1;
		case 7:
			return w2;
		default:
			return null;
		}
	}

	public int index(Point p) {
		int index = -1;
		if (p.equals(n1)) {
			index = 0;
		} else if (p.equals(n2)) {
			index = 1;
		} else if (p.equals(e1)) {
			index = 2;
		} else if (p.equals(e2)) {
			index = 3;
		} else if (p.equals(s1)) {
			index = 4;
		} else if (p.equals(s2)) {
			index = 5;
		} else if (p.equals(w1)) {
			index = 6;
		} else if (p.equals(w2)) {
			index = 7;
		}
		return index;
	}

	public int size() {
		int count = 0;
		for (int i = 0; i < 8; i++) {
			if (this.get(i) != null)
				count++;
		}
		return count;
	}
}
